package com.controller;

import com.entity.KechengxinxiEntity;
import com.entity.ZuoyebuzhiEntity;
import com.service.KechengxinxiService;
import com.service.ZuoyebuzhiService;
import com.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/zuoyebuzhi2")
public class Zuoyebuzhi2Controller {

    @Autowired
    private ZuoyebuzhiService zuoyebuzhiService;

    @Autowired
    private KechengxinxiService kechengxinxiService;

    @GetMapping("/kecheng/detail/{kechengId}")
    public R kecheng(@PathVariable("kechengId") Long kechengId) {
        KechengxinxiEntity kechengxinxiEntity = kechengxinxiService.selectById(kechengId);
        return R.ok().put("data", kechengxinxiEntity);
    }

    /**
     * 保存课题
     * @param zuoyebuzhiEntity
     * @return
     */
    @PostMapping("/keti")
    public R keti(@RequestBody ZuoyebuzhiEntity zuoyebuzhiEntity) {
        zuoyebuzhiService.insert(zuoyebuzhiEntity);
        return R.ok();
    }

}
